// 基于准备好的dom，初始化echarts实例
var myChart = echarts.init(document.getElementById('main'));

// 指定图表的配置项和数据
var option = {
    tooltip: {},
    series: [
        {
            type: 'graph',
            layout: 'none',
            symbolSize: 50,
            roam: true,
            label: {
                show: true,
                position: 'right'
            },
            edgeSymbol: ['circle', 'arrow'],
            edgeSymbolSize: [4, 10],
            edgeLabel: {
                fontSize: 12
            },
            data: [
                {name: '节点1', x: 200, y: 300},
                {name: '节点2', x: 400, y: 300},
                {name: '节点3', x: 600, y: 300},
                {name: '节点4', x: 800, y: 300}
            ],
            links: [
                {source: '节点1', target: '节点2'},
                {source: '节点2', target: '节点3'},
                {source: '节点3', target: '节点4'},
                {source: '节点4', target: '节点1'}
            ],
            lineStyle: {
                opacity: 0.9,
                width: 2,
                curveness: 0
            }
        }
    ]
};

// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);